using System;
using System.Linq;
using System.Diagnostics.Contracts;

namespace ReactiveCode.Statements
{
    class ImperativeStatement: ActionStatement<Unit>
    {
        Action _body;

        internal override bool MarkAsCurrent
        {
            get { return false; }
        }

        public ImperativeStatement(ObservableFactory<IObservable<Unit>> trigger, Action body)
        {
            Contract.Requires(trigger != null && body != null);
            Construct(trigger);
            _body = body;
        }

        protected override void Do(Unit _)
        {
            _body();
        }
    }
}